/* 
 * File:   scanner.h
 * Author: alexey
 *
 * Created on 30 Март 2011 г., 20:31
 */

#ifndef SCANNER_H
#define	SCANNER_H
#include <string.h>
#include <IStorage.h>
#include <IServiceLocator.h>
#include <IScanner.h>
#include <ITracer.h>
#include <auto_ptr.h>
#include <vector>
#include <boost/filesystem.hpp>

namespace storagemon
{

class Scanner : public IScanner
{
public:
    Scanner(IStorage* storage, IServiceLocator* sl);
    virtual ~Scanner();
    bool Tree();
    bool Scan();
private:
    bool ScanDirectoryTree(const char* dir, u_long parent_id, bool rec = true);
    bool ScanDirectory(std::vector<IDirectory*>::iterator dir);
    IFile* ScanFile(boost::filesystem::path file, u_long parent_id);
private:
    IStorage *m_storage;
    u_long m_id;
    u_long m_fileId;
    IServiceLocator* m_sl;
    IStorageServiceFactory* m_storageFactory;
    ITracer* m_tracer;

};

const char SCANNER_SERVICE[] = "scannerservice";

} // storagemon

#endif	/* SCANNER_H */

